﻿/*
  In App.xaml:
  <Application.Resources>
      <vm:ViewModelLocatorTemplate xmlns:vm="clr-namespace:MvvmLight1.ViewModel"
                                   x:Key="Locator" />
  </Application.Resources>
  
  In the View:
  DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"
*/

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;
using InternetBank.Model;

namespace InternetBank.ViewModel
{
    using InternetBank.BankService;
    using InternetBank.Model;

    using InternetBank.View;

    /// <summary>
    /// This class contains static references to all the view models in the
    /// application and provides an entry point for the bindings.
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class ViewModelLocator
    {
        static ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);


            //SimpleIoc.Default.Register<IPaymentsService, PaymentsServiceClient>();

            SimpleIoc.Default.Register<MainViewModel>();
            SimpleIoc.Default.Register<CredentialsViewModel>();
            SimpleIoc.Default.Register<PaymentModelBase>();
            SimpleIoc.Default.Register<PasswordModel>();
        }

        /// <summary>
        /// Gets the Main property.
        /// </summary>
        public MainViewModel Main
        {
            get
            {
                return ServiceLocator.Current.GetInstance<MainViewModel>();
            }
        }

        public CredentialsViewModel PasswordDialogWindow
        {
            get
            {
               return  new CredentialsViewModel();//return ServiceLocator.Current.GetInstance<CredentialsViewModel>();
            }
        }

        public PaymentModelBase MobilePaymentDialogWindow
        {
            get
            {
                return ServiceLocator.Current.GetInstance<PaymentModelBase>();
            }
        }

        public PasswordModel MCodeDialogWindow
        {
            get
            {
                return ServiceLocator.Current.GetInstance<PasswordModel>();
            }
        }

        /// <summary>
        /// Cleans up all the resources.
        /// </summary>
        public static void Cleanup()
        {
        }
    }
}